package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	public class FlowNumber extends Sprite
	{
		public function FlowNumber()
		{
			var i:int = 0;
			addEventListener(Event.ENTER_FRAME, frame);
		}
		
		private function randomnum():TextField
		{
			var txt:TextField = new TextField();
			txt.width = 12;
			txt.textColor = 0x00ff00;
			txt.addEventListener(Event.ENTER_FRAME, f);
			
			function f(e):void
			{
				e.target.text = int(Math.random() * 10);
			}
			
			return txt;
		}
		
		private function spnum():Sprite
		{
			var sp:Sprite = new Sprite();
			for (var j:int = 0; j < 10; j++)
			{
				var txt:TextField = randomnum();
				sp.addChild(txt);
				txt.y = j * 30;
			}
			return sp;
		}
		
		private function movenum():Sprite
		{
			var sp:Sprite = spnum();
			addChild(sp);
			sp.x = Math.random() * 550;
			sp.y = Math.random() * (-250);
			sp.alpha = Math.random() + 1;
			sp.scaleX = sp.scaleY = Math.random() * .5 + 1;
			sp.addEventListener(Event.ENTER_FRAME, movef);
			
			function movef(e):void
			{
				sp.y += Math.random()*5 + 5;
				if (sp.y > 400)
				{
					sp.x = Math.random() * 550;
					sp.y = Math.random() * (-250);
				}
			}
			
			return sp;
		}
		
		private function frame(e):void
		{
			var sp:Sprite = movenum();
			addChild(sp);
			var i:int = 0;
			i++;
			if (i == 40)
			{
				removeEventListener(Event.ENTER_FRAME, frame);
			}
		}
	}
}